fix(abilities): flatten category slugs for WP 7.0 compatibility#223
Merged
fix(abilities): flatten category slugs for WP 7.0 compatibility#223
Conversation
WordPress 7.0 RC2 tightened the Abilities API category slug validation regex to /^[a-z0-9]+(?:-[a-z0-9]+)*$/, rejecting any slug containing a forward slash. The 'datamachine-events/events', 'datamachine-events/venues', etc. category slugs that worked silently on 6.9 now fail registration on 7.0+, and every ability assigned to those categories logs "category is not registered" notices on every init (~13,000 lines per few minutes on a busy site). Flatten the four category slugs to match Data Machine core's pattern of '<plugin>-<category>' (e.g. 'datamachine-content', 'datamachine-media'): datamachine-events/events -> datamachine-events-events datamachine-events/venues -> datamachine-events-venues datamachine-events/testing -> datamachine-events-testing datamachine-events/settings -> datamachine-events-settings Ability *names* (e.g. 'data-machine-events/get-venue-events') continue to use the slash-separated namespace/name format — that is still valid and required by the Abilities API registration regex. Refs: data-machine-events#216
Contributor
Homeboy Results —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WordPress 7.0 RC2 tightened the Abilities API category slug validation regex to
/^[a-z0-9]+(?:-[a-z0-9]+)*$/, rejecting any slug containing a forward slash. Thedatamachine-events/events,datamachine-events/venues, etc. category slugs that worked silently on 6.9 now fail registration on 7.0+, and every ability assigned to those categories logscategory is not registerednotices on every init.On a busy production site (extrachill.com network), this generates ~13,000 notices per few minutes and was filling debug.log to multi-GB scale within hours of the WP 7.0 upgrade.
Fix
Flatten the four category slugs to match Data Machine core's pattern of
<plugin>-<category>(e.g.datamachine-content,datamachine-media):Scope
data-machine-events/get-venue-events) keep theirnamespace/nameslash format — that is still valid and required by the Abilities API name regex.Verification
Refs: data-machine-events#216